package com.jyh.dao;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface BookShopDao {

    /**
    * Description:根据编号查询价格
    * @date: 2022/11/14 17:09
    * @param:
    * @return:
    */
    @Select("select price from book where isbn=#{isbn}")
    int findBookPriceByIsbn(String isbn);

    /**
    * Description:根据编号修改库存
    * @date: 2022/11/14 17:09
    * @param:
    * @return:
    */
    @Update("update book_stock set stock=stock-1 where isbn=#{isbn}")
    public void updateBookStock(String isbn);

    /**
    * Description:根据用户名和金额修改账户余额
    * @date: 2022/11/14 17:14
    * @param:
    * @return:
    */
    @Update("update account set balance=balance-#{money} where username=#{username}")
    public void updateByUsername(@Param("username") String username,@Param("money") int money);

    /**
    * Description:根据用户名查询余额
    * @date: 2022/11/14 17:16
    * @param:
    * @return:
    */
    @Select("select balance from account where username=#{username}")
    int findBalanceByUsername(String username);

    /**
    * Description:查询库存
    * @date: 2022/11/14 17:22
    * @param:
    * @return:
    */
    @Select("select stock from book_stock where isbn=#{isbn}")
    public int findStockByIsbn(String isbn);
}
